# Maintainer: BlackIkeEagle <ike DOT devolder AT gmail DOT com>
# Contributor: Cedric Girard <cgirard.archlinux@valinor.fr>
# Contributor: kevku <kevku@gmx.com>

pkgname=kodi-addon-inputstream-adaptive
pkgver=20.3.6
_codename=Nexus
pkgrel=1
pkgdesc="InputStream client for adaptive streams for Kodi 18+"
arch=('loong64' 'x86_64')
url="https://github.com/peak3d/inputstream.adaptive"
license=('GPL2')
groups=('kodi-addons' 'kodi-addons-inputstream')
makedepends=('cmake' 'kodi-dev' 'gtest')
options=(!lto)

_bento4_version="1.6.0-639-5"

source=("$pkgname-$pkgver.tar.gz::https://github.com/peak3d/inputstream.adaptive/archive/$pkgver-$_codename.tar.gz"
        "$pkgname-bento4-$_bento4_version.tar.gz::https://github.com/xbmc/Bento4/archive/refs/tags/$_bento4_version-$_codename.tar.gz")
noextract=("$pkgname-bento4-$_bento4_version.tar.gz")
sha512sums=('010af7abfeeed375d4c3457f5d7a9aa848edbf247427b72f64f1f4e26870ad39ec4a9b1e6bc9479ce41dc01779f9a7d0bdbb8f005f7e8afde9ea59f9e31d879d'
            '8628c6b7f9cdd16fb2fb92848ce3248559e5160e2bb6d19da23634340e69c533b14775def77e897f1f030bedb9a0caa54d0645a3b39a22514b4ab844b63203aa')

build() {
    cd "inputstream.adaptive-$pkgver-$_codename"
    cmake \
        -DCMAKE_INSTALL_PREFIX=/usr \
        -DCMAKE_BUILD_TYPE=Release \
        -DBUILD_SHARED_LIBS=1 \
        -DUSE_LTO=1 \
        -DENABLE_INTERNAL_BENTO4=1 \
        -DBENTO4_URL="$srcdir/$pkgname-bento4-$_bento4_version.tar.gz" \
        .
    make
}

package() {
    depends=('kodi' 'kodi-platform')
    cd "inputstream.adaptive-$pkgver-$_codename"
    make DESTDIR="$pkgdir/" install
}
